
let activity_tag = 'ysfsfq'
let request_key = 'help'

function sfqcj($request,body) {
    console.log(`开始完成玩游戏抽奖`);
    console.log(body)
    // axios_skill($request)
    var score = randomNum(60000*2,60000*3)    
    setTimeout(axios_skill,score,$request);
}

//上面是暂时需要适配的部分
!(async () => {
    if (typeof $request !== "undefined") {
        let body = $response.body;
        $done(body)
        sfqcj($request,body)
    }
})()
    .catch((e) => console.log(e))
    .finally(() => $done())

function axios_skill(request_body) {
    // console.log('第'+count+'次游戏');
    var request_lib = require('request');
    var headers = {
        'Accept': 'application/json, text/plain, */*',
        'Authorization': request_body.headers.Authorization,
        'Accept-Language': 'zh-cn',
        'Content-Type': 'application/json',
        'Origin': 'https://youhui.95516.com',
        'User-Agent':  request_body.headers['User-Agent'],
        'Connection': 'keep-alive',
        'Referer': 'https://youhui.95516.com/newsign/ysfsfq/index.html',
        'Cookie': request_body.headers.Cookie
    };
    var score = randomNum(800,1000)
    let body = $response.body;
    body = JSON.parse(body)
    var dataString = '{"score":'+score+',"token":"'+body.data+'"}';
    // console.log(headers);
    console.log(dataString);
    var options = {
        url: 'https://youhui.95516.com/newsign/ysfsfq/api/game/lottery',
        method: 'POST',
        headers: headers,
        body: dataString
    };
    request_lib(options, callback);

}

function callback(error, response, body) {
    console.log(body);
}

//生成从minNum到maxNum的随机数
function randomNum(minNum, maxNum) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * minNum + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
            break;
        default:
            return 0;
            break;
    }
}